/*    */ package com.bj58.analysis.tools.common;
/*    */ 
/*    */ import javax.crypto.Cipher;
/*    */ import javax.crypto.SecretKey;
/*    */ import javax.crypto.SecretKeyFactory;
/*    */ import javax.crypto.spec.DESKeySpec;
/*    */ import javax.crypto.spec.IvParameterSpec;
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ public class EncryptHelper
/*    */ {
/* 20 */   private static String strParam = "queryivs"; private static String strKey = "infolist";
/*    */   
/*    */   public static String desEncrypt(String source) throws Exception {
/* 23 */     if ((source == null) || (source.length() == 0))
/* 24 */       return null;
/* 25 */     Cipher cipher = Cipher.getInstance("DES/CBC/PKCS5Padding");
/* 26 */     DESKeySpec desKeySpec = new DESKeySpec(strKey.getBytes("UTF-8"));
/* 27 */     SecretKeyFactory keyFactory = SecretKeyFactory.getInstance("DES");
/* 28 */     SecretKey secretKey = keyFactory.generateSecret(desKeySpec);
/* 29 */     IvParameterSpec iv = new IvParameterSpec(strParam.getBytes("UTF-8"));
/* 30 */     cipher.init(1, secretKey, iv);
/* 31 */     return StringHelper.toHexString(cipher.doFinal(source.getBytes("UTF-8"))).toUpperCase();
/*    */   }
/*    */   
/*    */   public static String desDecrypt(String source) throws Exception {
/* 35 */     if ((source == null) || (source.length() == 0))
/* 36 */       return null;
/* 37 */     byte[] src = StringHelper.fromHexString(source);
/* 38 */     Cipher cipher = Cipher.getInstance("DES/CBC/PKCS5Padding");
/* 39 */     DESKeySpec desKeySpec = new DESKeySpec(strKey.getBytes("UTF-8"));
/* 40 */     SecretKeyFactory keyFactory = SecretKeyFactory.getInstance("DES");
/* 41 */     SecretKey secretKey = keyFactory.generateSecret(desKeySpec);
/* 42 */     IvParameterSpec iv = new IvParameterSpec(strParam.getBytes("UTF-8"));
/* 43 */     cipher.init(2, secretKey, iv);
/* 44 */     byte[] retByte = cipher.doFinal(src);
/* 45 */     return new String(retByte, "UTF-8");
/*    */   }
/*    */ }


/* Location:              C:\Users\zhaoxiang\Desktop\basestat_log_common_tools-0.3.jar!\com\bj58\analysis\tools\common\EncryptHelper.class
 * Java compiler version: 5 (49.0)
 * JD-Core Version:       0.7.1
 */